﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


class SelectionSort
{
    static void Main()
    {
        int[] arr = { 4, 1, 2, 3, 4, 3, 2, 2, 1 };
        int swap;
        int index;
        for (int i = 0; i < arr.Length - 1; i++)
        {
            index = i;
            for (int j = i + 1; j < arr.Length; j++)
            {
                if (arr[index] > arr[j])
                {
                    index = j;                   
                }
            }

            if (index != i)
            {
                swap = arr[index];
                arr[index] = arr[i];
                arr[i] = swap;
            }
        }

        for (int i = 0; i < arr.Length; i++)
        {
            Console.WriteLine(arr[i]);
        }
    }
}

